package com.zfj.eduService;

import com.alibaba.excel.EasyExcel;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangfujing
 * @date 2022/10/6 10:27
 */
public class testEasyExcel {
    public static void main(String[] args) {
        //实现excel写操作
        //设置写入文件夹地址和excel文件名称
//        String fileName="D:\\write.xlsx";
//        //调用excel方法实现写操作
//        EasyExcel.write(fileName,DemoData.class).sheet("学生列表")
//        .doWrite(getData());


        //实现excel读操作
        String fileName="D:\\write.xlsx";
        EasyExcel.read(fileName,DemoData.class,new excelListener()).sheet().doRead();

    }
    //创建方法返回list集合
    private static List<DemoData> getData(){
        List<DemoData> list=new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            DemoData data = new DemoData();
            data.setSno(i);
            data.setSname("lucky"+i);
            list.add(data);
        }
        return list;
    }
}
